package cn.sdhuijin.healthexam.activity;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.Properties;

import android.content.Intent;
import android.os.Bundle;
import android.os.Environment;
import android.view.View;
import android.view.View.OnClickListener;
import cn.sdhuijin.healthexam.ExitApplication;
import cn.sdhuijin.healthexam.R;
import cn.sdhuijin.healthexam.control.AbstractControlActivity;

/**
 * 新生儿家庭访视记录表
 * 
 * @author sunping
 */
public class NewChildrenVisitInfoActivity extends AbstractControlActivity
		implements OnClickListener {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_newchild_info);
		ExitApplication.getInstance().addActivity(this);

		Intent intent = getIntent();
		// 获取传递过来的sql语句
		String fileName = intent.getStringExtra("filename");

		addTextView(R.id.txt_user_name, "姓名");
		addTextView(R.id.txt_identify_num, "身份证号");
		addTextView(R.id.txt_user_sex, "性别_content");
		addTextView(R.id.txt_user_birth, "出生日期");
		addTextView(R.id.txt_home_address, "家庭住址");
		addTextView(R.id.txt_chushengyunzhou, "出生孕周");
		addTextView(R.id.txt_father_name, "父亲姓名");
		addTextView(R.id.txt_father_work, "父亲职业");
		addTextView(R.id.txt_father_phone, "父亲联系电话");
		addTextView(R.id.txt_father_birthdate, "父亲出生日期");
		addTextView(R.id.txt_mother_name, "母亲姓名");
		addTextView(R.id.txt_mother_work, "母亲职业");
		addTextView(R.id.txt_mother_phone, "母亲联系电话");
		addTextView(R.id.txt_mother_birthdate, "母亲出生日期");
		addTextView(R.id.txt_mother_renshenhuanbing, "母亲妊娠期患病情况_content");
		addTextView(R.id.txt_mother_renshenhuanbing_qt, "母亲妊娠期患病情况其它");
		addTextView(R.id.txt_zhuchanjigou, "助产机构名称");
		addTextView(R.id.txt_chushengqingkuang, "出生情况_content");
		addTextView(R.id.txt_chushengqingkuang_qt, "出生情况其他");
		addTextView(R.id.txt_zhixi, "新生儿窒息_content");
		addTextView(R.id.txt_jixing, "畸型_content");
		addTextView(R.id.txt_tinglishaixuan, "新生儿听力筛查_content");
		addTextView(R.id.txt_jibingshaixuan, "新生儿疾病筛查_content");
		addTextView(R.id.txt_chushengtizhong, "新生儿出生体重");
		addTextView(R.id.txt_muqiantizhong, "目前体重");
		addTextView(R.id.txt_chushengshengao, "出生身长");
		addTextView(R.id.txt_weiyangfangshi, "喂养方式_content");
		addTextView(R.id.txt_chinailiang, "吃奶量");
		addTextView(R.id.txt_chinaicishu, "吃奶次数");
		addTextView(R.id.txt_outu, "呕吐_content");
		addTextView(R.id.txt_dabian, "大便_content");
		addTextView(R.id.txt_dabiancishu, "大便次数");
		addTextView(R.id.txt_tiwen, "体温");
		addTextView(R.id.txt_mailv, "脉率");
		addTextView(R.id.txt_huxipinlv, "呼吸频率");
		addTextView(R.id.txt_mianse, "面色_content");
		addTextView(R.id.txt_mianse_qt, "面色其他");
		addTextView(R.id.txt_huanggenbuwei, "黄疸部位_content");
		addTextView(R.id.txt_qianxin_first, "前囟一");
		addTextView(R.id.txt_qianxin_second, "前囟二");
		addTextView(R.id.txt_qianxin, "前囟_content");
		addTextView(R.id.txt_qianxin_qt, "前囟其他");
		addTextView(R.id.txt_yanwaiguan, "眼外观_content");
		addTextView(R.id.txt_sizhouhuodongdu, "四肢活动度_content");
		addTextView(R.id.txt_erwaiguan, "耳外观_content");
		addTextView(R.id.txt_jingbubaokuai, "颈部包块_content");
		addTextView(R.id.txt_bi, "鼻_content");
		addTextView(R.id.txt_pifu, "皮肤_content");
		addTextView(R.id.txt_pifu_qt, "皮肤其他");
		addTextView(R.id.txt_kouqiang, "口腔_content");
		addTextView(R.id.txt_gangmen, "肛门_content");
		addTextView(R.id.txt_xinfeitingzhen, "心肺听诊_content");
		addTextView(R.id.txt_waishengzhiqi, "外生殖器_content");
		addTextView(R.id.txt_fubuchuzhen, "腹部触诊_content");
		addTextView(R.id.txt_jizhu, "脊柱_content");
		addTextView(R.id.txt_jidai, "脐带_content");
		addTextView(R.id.txt_jidai_qt, "脐带其他");
		addTextView(R.id.txt_zd, "指导_content");
		addTextView(R.id.txt_zhuanzhen, "转诊_content");
		addTextView(R.id.txt_zhuanzhen_yy, "转诊原因");
		addTextView(R.id.txt_zhuanzhen_jgjks, "机构及科室");
		addTextView(R.id.txt_next_date, "下次随访日期");
		addTextView(R.id.txt_visit_doctor, "随访医生签名");
		addTextView(R.id.txt_next_place, "下次随访地点");
		addTextView(R.id.txt_suggestion, "指导意见");

		setButtonListener(this, R.id.btn_back);

		Properties prop = new Properties();
		try {
			File f = new File(Environment.getExternalStorageDirectory()
					.getPath() + "/health/" + fileName + ".txt");
			if (f.exists()) {

				controlManager.setPropertiesPath(f.getAbsolutePath());
				controlManager.toControl();

				prop.load(new FileReader(f.getAbsolutePath()));
			} else {
				this.toastInformation(R.string.record_deleted);
			}
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	@Override
	public void onClick(View v) {
		int clickId = (Integer) v.getId();
		switch (clickId) {
		case R.id.btn_back:
			finish();
			break;
		default:
			break;
		}
	}

}
